package com.ruoyi.web.controller.shopweb;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopScene;
import com.ruoyi.system.service.IShopSceneService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用场景信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/system/scene")
public class ShopSceneController extends BaseController
{
    @Autowired
    private IShopSceneService shopSceneService;

    /**
     * 查询应用场景信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:scene:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopScene shopScene)
    {
        startPage();
        List<ShopScene> list = shopSceneService.selectShopSceneList(shopScene);
        return getDataTable(list);
    }

    /**
     * 导出应用场景信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:scene:export')")
    @Log(title = "应用场景信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopScene shopScene)
    {
        List<ShopScene> list = shopSceneService.selectShopSceneList(shopScene);
        ExcelUtil<ShopScene> util = new ExcelUtil<ShopScene>(ShopScene.class);
        util.exportExcel(response, list, "应用场景信息数据");
    }

    /**
     * 获取应用场景信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scene:query')")
    @GetMapping(value = "/{sceneId}")
    public AjaxResult getInfo(@PathVariable("sceneId") Long sceneId)
    {
        return success(shopSceneService.selectShopSceneBySceneIdTwo(sceneId));
    }

    /**
     * 新增应用场景信息
     */
    @PreAuthorize("@ss.hasPermi('system:scene:add')")
    @Log(title = "应用场景信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopScene shopScene)
    {
        return toAjax(shopSceneService.insertShopScene(shopScene));
    }

    /**
     * 修改应用场景信息
     */
    @PreAuthorize("@ss.hasPermi('system:scene:edit')")
    @Log(title = "应用场景信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopScene shopScene)
    {
        return toAjax(shopSceneService.updateShopScene(shopScene));
    }

    /**
     * 删除应用场景信息
     */
    @PreAuthorize("@ss.hasPermi('system:scene:remove')")
    @Log(title = "应用场景信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sceneIds}")
    public AjaxResult remove(@PathVariable Long[] sceneIds)
    {
        return toAjax(shopSceneService.deleteShopSceneBySceneIds(sceneIds));
    }
}
